package gov.pbc.nn.kjgl.fxq.infoResearch.view;

import java.util.Collection;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import com.bstek.dorado.annotation.DataProvider;

import gov.pbc.nn.core.dao.CommonHibernateDao;
import gov.pbc.nn.kjgl.fxq.infoResearch.entity.HistoryDocEntity;

@Component(HistoryDocDao.BEAN_ID)
public class HistoryDocDao extends CommonHibernateDao {
	public static final String BEAN_ID = "historyDocDao";
	
	@DataProvider
	public Collection<HistoryDocEntity> getHistoryDocsByirId(String irId) throws Exception {
		DetachedCriteria detachedCriteria=DetachedCriteria.forClass(HistoryDocEntity.class);
		detachedCriteria.add(Restrictions.eq("invalid",false));
		detachedCriteria.add(Restrictions.eq("irId", irId));
		detachedCriteria.addOrder(Order.desc("createDate"));
		return (Collection<HistoryDocEntity>) this.query(detachedCriteria);
	}
}
